package br.usp.poli.compilador2008.syntatic;

import java.util.ArrayList;
import java.util.Hashtable;


/**SubMachine class - this class is used to manipulate the submachines 
 * 
 * @author ashimono
 *
 */
public final class SubMachine {
	private SubMachs currentSubMachine;
	private  ArrayList<Transition> subMachTransitions;
	private  ArrayList<Integer> subMachFinalStates;
	
	
	/** getInstanceOf - Returns an instance of the type SubMachine, which is basically a
	 * capsule for the SubMach given, and contains the list of possible transitions and final states.
	 * 
	 * @param SubMachs type
	 * @return SubMachine
	 */
	public SubMachine(SubMachs type){
	SyntaticTables.start();	//populates all possible transitions for each subMachine
	Hashtable<SubMachs, ArrayList<Integer>> finalStates = SyntaticTables.getSubMachFinalStates();
	this.subMachFinalStates = finalStates.get(type);
	

	
	Hashtable<SubMachs, ArrayList<Transition>> transitions = SyntaticTables.getSubMachTransitions();
	this.subMachTransitions = transitions.get(type);
	
	this.currentSubMachine = type;
		
	}

	public ArrayList<Transition> getSubMachTransitions() {
		return subMachTransitions;
	}

	public void setSubMachTransitions(ArrayList<Transition> subMachTransitions) {
		this.subMachTransitions = subMachTransitions;
	}

	public ArrayList<Integer> getSubMachFinalStates() {
		return subMachFinalStates;
	}

	public void setSubMachFinalStates(ArrayList<Integer> subMachFinalStates) {
		this.subMachFinalStates = subMachFinalStates;
	}

	public SubMachs getCurrentSubMachine() {
		return this.currentSubMachine;
	}

	public void setCurrentSubMachine(SubMachs currentSubMachine) {
		this.currentSubMachine = currentSubMachine;
	}
	
	
}
